Reduce code complexity by extracting helpers and eliminating duplication#4
Draft
Reduce code complexity by extracting helpers and eliminating duplication#4
Conversation
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
…plication Co-authored-by: domfahey <789732+domfahey@users.noreply.github.com>
Co-authored-by: domfahey <789732+domfahey@users.noreply.github.com>
Co-authored-by: domfahey <789732+domfahey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Identify improvements for overly complex code
Reduce code complexity by extracting helpers and eliminating duplication
Dec 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several functions exceeded cyclomatic complexity thresholds (CC 12-20), and ~100 lines of error handling were duplicated between sync and async clients.
Changes
Shared Error Handler
error_handler.pywithhandle_error_response()functionDexClientandAsyncDexClientdelegate to shared implementationDeduplication Module Refactoring
merge_cluster(CC 16→3)_select_primary_row(): Primary contact selection logic_merge_contact_fields(): Field merging with null-coalescing_consolidate_related_records(): Email/phone consolidation and deduplicationfind_fuzzy_name_duplicates(CC 12→3)_create_soundex_blocks(): Soundex-based blocking for O(n²)→O(n) reduction_find_matches_in_block(): Jaro-Winkler similarity matching within blocksScript Refactoring
review_duplicates.py:main(CC 20→10)_fetch_unresolved_groups(): Database query isolation_display_contact_group(): Rich table rendering_handle_user_choice(): User input processingsync_with_integrity.py:save_contacts_batch(CC 12→8)_check_contact_changed(): Hash comparison and metadata retrieval_enrich_contact_data(): Name parsing and job title extraction_save_contact_related_data(): Email/phone persistenceExample
Before:
After:
Testing
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.